Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PURE plugin fix & warn on load error #113

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

PURE plugin fix & warn on load error #113

wants to merge 5 commits into from

Conversation

bard
Copy link

@bard bard commented Oct 11, 2011

Deals with a couple of issues that bit me on my first day with SammyJS.

The second is more of a beginning of a fix (I haven't looked into Sammy's own logging facilities yet).

…autoRender() with directives leads to unexpected results.

Before the fix, this test case results in the error "The node
.summary-text" was not found in the template" being printed to the
console and the template not being processed as expected.

    <!DOCTYPE html>
    <html>
      <head>
        <script type="text/javascript" src="js/jquery.min.js"></script>
        <script type="text/javascript" src="js/pure.js"></script>
        <script type="text/javascript" src="js/sammy/sammy.js"></script>
        <script type="text/javascript" src="js/sammy/plugins/sammy.pure.js"></script>
        <script type="text/javascript">
            var app = $.sammy('#main', function() {
                this.use('Pure');

                this.get('#/', function(context) {
                    var data = {
                        summary: 'buy bread',
                        state: 'done'
                    };
                    var directives = {
                        '.summary-text': 'summary',
                        '.state': 'state'
                    };

                    context.pure('#main', data, directives);
                });
            });

            $(document).ready(function() {
                app.run('#/');
            });
        </script>
      </head>
      <body>
        <div id="main">
          <div class="summary">[<span class="state"></span>] <span class="summary-text"></span></div>
        </div>
      </body>
    </html>
Example:

this.get('#/foo/bar', function(context) {
    // business as usual
}, function() {
    // run when user navigates away from #/foo/bar
    // useful e.g. to undo anything specific to the #/foo/bar view
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant